NexusFi: Find Your Edge


Home Menu

 





Java Adj Trailing stop strategy help please :)


Discussion in NinjaTrader

Updated
    1. trending_up 1,304 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread

Java Adj Trailing stop strategy help please :)

  #1 (permalink)
sickwake
Vancouver BC Canada
 
Posts: 1 since Feb 2014
Thanks Given: 0
Thanks Received: 0

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) {
System.out.println(TrailStop2);
if (TrailStop2 == .05 - TargetPrice );
System.out.println(TrailStop3);
}else{
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

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Cheap historycal L1 data for stocks
Stocks and ETFs
How to apply profiles
Traders Hideout
 




Last Updated on February 13, 2014


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts