NexusFi: Find Your Edge


Home Menu

 





problem with stop order in easylanguage


Discussion in EasyLanguage Programming

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




 
Search this Thread
  #1 (permalink)
cong93
toronto, canada
 
Posts: 2 since Mar 2019
Thanks Given: 0
Thanks Received: 0

Hi i want to make a strategy in easylanguage that would be triggered based on an indicator, then enter a limit order to short on the next candle, at a fixed amount away from this candle's high. i also want to risk off the high of this candle. below are two of my attempts at the code:

If marketposition = 0 then begin
If tigger > tiggeramount then
sellshort ("enter short") 1000 shares next bar at (high - offthehigh) limit;
Buytocover ("exit stop") 1000 shares next bar At (high) stop;
end;
If marketposition = -1 then begin
Buytocover ("exit profit") 1000 shares next bar At (entryprice - offtheentry) limit;
end;

this one for some reason randomly gets rid of my stop order sometimes, leaving me with unlimited risk.....


If marketposition = 0 then begin
If tigger > tiggeramount then
sellshort ("enter short") 1000 shares next bar at (high - offthehigh) limit;
end;
If marketposition = -1 then begin
Buytocover ("exit stop") 1000 shares next bar At (entryprice + offthehigh) stop;
Buytocover ("exit profit") 1000 shares next bar At (entryprice - offtheentry) limit;
end;

this one only makes a stop order AFTER the candle that i got in on had closed. what if i got in and the candle closed much higher than the amount /share i wanted to risk? it doesnt make sense either.

how do i make this work?


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
UMA Votes Tonight: Polymarkets $80M Strategy Bitcoin Bat …
Prediction Markets & Event Contracts
Hormuz Surges From 14% to 26.5% Intraday as Irans Answer …
Prediction Markets & Event Contracts
Warsh Drops Easing Bias, December Hike Now Above 50% -- …
Prediction Markets & Event Contracts
April 2026 Jobs Report: +115k vs +65k Expected
Traders Hideout
Fed Hike Odds at 57% After Warsh: England Surges 12.9%, …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
15 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,643


Hi cong93,

your first code only issues the stop while you are flat i.e. once you are in a position the stop would not be issued anymore.
Without intrabar order generation your second code snippet will only be aware of the fill at the end of the entry bar and issue the stop for the next bar then.

You could for example store the high of a bar within a variable while you are flat and issue the stop order unconditionally using this variable as stop price.

Regards,

ABCTG


Follow me on X Reply With Quote
  #4 (permalink)
cong93
toronto, canada
 
Posts: 2 since Mar 2019
Thanks Given: 0
Thanks Received: 0

Hi ABCTG I tried to do that by adding in a variable to equal the “high” while the position was flat, then set the stop order to that variable, however I think that variable’s value seem to change to the high of every single closed candle afterwards and constantly moving my stop to the previous candles high


i tried the intrabar generation, that seems to also mess up my indicator's calculation and cause me to take trades where i wouldnt want to.
another solution i can think of might be to make a loop to increase the index of the high which each new candle, high[1] then high[2], high[3]... and refer back to that candle. but that could be a problem if for example i have an order out to short, and it fills me 3 candles after, then id have to start counting from high[2], so id also have to check where i got filled.
this seems like a lot of work for a very simple task with easylanguage. there must be an easier way


Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,643

Hi cong93,

it sounds like your code also allowed updating the variable while you are in a position, but without seeing the code this is just a guess.

Regards,

ABCTG


cong93 View Post
Hi ABCTG I tried to do that by adding in a variable to equal the “high” while the position was flat, then set the stop order to that variable, however I think that variable’s value seem to change to the high of every single closed candle afterwards and constantly moving my stop to the previous candles high


i tried the intrabar generation, that seems to also mess up my indicator's calculation.
another solution i can think of might be to make a loop to increase the index of the high which each new candle, and refer back to that candle. but that could be a problem if for example i have an order out to short, and it fills me 3 candles after. id also have to check where i got filled.
this seems like a lot of work for a very simple task with easylanguage. there must be an easier way


Follow me on X Reply With Quote




Last Updated on March 7, 2019


© 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