NexusFi: Find Your Edge


Home Menu

 





Java Adj Trailing stop strategy help please :)


Discussion in NinjaTrader

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




 
Search this Thread
  #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?
CFTC Approves First US Bitcoin Perpetual Futures -- Kals …
Traders Hideout
Sundays Verdict: Lebanon Locked at 99.85% as Iran June 7 …
Prediction Markets & Event Contracts
Hormuz Completely Closed: US Strikes Day 2, Iran Shoots …
Traders Hideout
Peace Deal Forward Curve: May 22%, June 51%, December 81 …
Prediction Markets & Event Contracts
Hormuz Surges From 14% to 26.5% Intraday as Irans Answer …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
13 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks




Last Updated on February 13, 2014


© 2026 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 - Downloads - Top
no new posts