Java Adj Trailing stop strategy help please :) - NinjaTrader Programming | futures trading

Go Back

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > NinjaTrader Programming

Java Adj Trailing stop strategy help please :)
Started:February 13th, 2014 (07:31 PM) by sickwake Views / Replies:365 / 1
Last Reply:February 13th, 2014 (07:31 PM) Attachments:0

Welcome to

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community. It's free and simple, and we will never resell your private information.

-- Big Mike

Thread Tools Search this Thread

Java Adj Trailing stop strategy help please :)

Old February 13th, 2014, 07:31 PM   #1 (permalink)
Trading Apprentice
Vancouver BC Canada
Futures Experience: Intermediate
Platform: TWS
Favorite Futures: stocks
Posts: 1 since Feb 2014
Thanks: 0 given, 0 received

Java Adj Trailing stop strategy help please :)

Hey guys,

New at Programming. Using Java to code my strategy for automated day trading. My plan is simple. Just need some help with the code and where to go from here.

The plan is to have a trailing stop that adjusts as the market moves in favour of the trade. For Example (Going Long/buying): Enter the market at specified entry price and it moves up in favour of the trade. When the price reaches 50% of the way between entry price and target price the trailing stop is adjusted and is adjusted one last time when target price is reached.

What I have thus far... (A really rough first draft as you can see!)

public class StockExample {
public static void main(String[] args) {
double MarketPrice;
double EntryPrice; // EntryPrice == Stop Price
double TargetPrice;
double TrailStop;
double TrailStop2; //Initial Trail Adjusted 50%
double TrailStop3; //Trails .05 behind TargetPrice
TrailStop2 = TargetPrice - EntryPrice/2 +.02;
TrailStop3 = TargetPrice - .05;

if (TrailStop == 50% TargetPrice) {
if (TrailStop2 == .05 - TargetPrice );
System.out.println("Target Price not met.");

Also wanting to add this new rule and convert it to code...

If Market price exceeds Entry Price by .15 and is not triggered cancel trade ( like a gap were to occur or something)
Figure it would have to look something like this?

if (MarketPrice > EntryPrice + 0.15)
System.out.println("Cancel Trade");

Any help will be appreciated. Cheers

Reply With Quote

Old February 13th, 2014, 07:31 PM   #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.


Reply > Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > NinjaTrader Programming > Java Adj Trailing stop strategy help please :)

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Upcoming Webinars and Events (4:30PM ET unless noted)

An Afternoon with FIO trader bobwest

Elite only

NinjaTrader 8: Programming Profitable Trading Edges w/Scott Hodson

Elite only

Anthony Drager: Executing on Intermarket Correlations & Order Flow, Part 2

Elite only

Adam Grimes: Five critically important keys to professional trading

Elite only

Machine Learning Concepts w/FIO member NJAMC

Elite only

MarketDelta Cloud Platform: Announcing new mobile features

Dec 1

NinjaTrader 8: Features and Enhancements

Dec 6

Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Trailing Stop Strategy sandptrader NinjaTrader 18 August 8th, 2016 06:47 PM
Using SuperTrend for trailing stop in a strategy - help needed DarrenH NinjaTrader Programming 13 June 25th, 2014 07:07 PM
Ninjatrader strategy for Trailing Stop and stop loss. skann NinjaTrader 2 August 20th, 2013 07:34 PM
Simple trailing stop strategy jeemba EasyLanguage Programming 2 August 2nd, 2013 07:05 AM
Exit at close for trailing stop strategy skorpyo ThinkOrSwim Programming 0 July 27th, 2013 04:56 AM

All times are GMT -4. The time now is 11:07 AM.

Copyright © 2016 by All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts

Page generated 2016-10-21 in 0.08 seconds with 19 queries on phoenix via your IP