Another Trail Stop question - futures io
futures io



Another Trail Stop question


Discussion in EasyLanguage Programming

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




Welcome to futures io: the largest futures trading community on the planet, with well over 150,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
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.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Another Trail Stop question

(login for full post details)
  #1 (permalink)
gurji
Miami, Florida
 
 
Posts: 25 since Apr 2022
Thanks: 1 given, 8 received

I will try to make this as simple as I can.

I place a long order at $90.

My stop loss is $80.

My Target is $100.


Now I want to add a trail stop. So instead of the $100 target, I want the following:
When price reaches $100, then create a $5 trail stop.

So if it reaches $100, the worst I will get is $95. If it continues up to $115 and goes back down to $110, then it will exit at $110.

If it reaches $105 and goes back to $100, it will exit at $100.


How can I set this in easylanguage?

Reply With Quote

Can you help answer these questions
from other members on futures io?
Effect of Bitcoin price on Altcoins
Crypto Futures
SafeDayTradingorg
Trading Reviews and Vendors
East West Petroleum Corp - EW (Canada) – EWPMF (USA) …
Stocks and ETFs
Realtest vs Amibroker
Platforms and Indicators
Jumpstart Trading
Trading Reviews and Vendors
 
 
(login for full post details)
  #2 (permalink)
 syswizard 
Philadelphia PA
 
Experience: Advanced
Platform: Multicharts
Broker: Ironbeam, Rithmic
Trading: Emini ES / NQ / CL / RTY / YM / BTC
 
syswizard's Avatar
 
Posts: 223 since Jan 2019
Thanks: 12 given, 101 received

if MarketPosition <> 0 and OpenPositionProfit >= 100 Then
Begin
SetStopPosition;
SetDollarTrailing(100);
End;

Reply With Quote
 
(login for full post details)
  #3 (permalink)
gurji
Miami, Florida
 
 
Posts: 25 since Apr 2022
Thanks: 1 given, 8 received



syswizard View Post
if MarketPosition <> 0 and OpenPositionProfit >= 100 Then
Begin
SetStopPosition;
SetDollarTrailing(100);
End;


Thanks, but something still not right. This is what I have. tgamt is trigger amount in ticks for when to start the trail stop.
slamt is the stop loss amount in ticks.

 
Code
SetStopLoss(slamt);

if MarketPosition <> 0 and Openpositionprofit >= tgamt Then
	Begin
		SetStopPosition;
		SetDollarTrailing(50); //50 is $50 which is 5 ticks.
	End

Reply With Quote
 
(login for full post details)
  #4 (permalink)
 syswizard 
Philadelphia PA
 
Experience: Advanced
Platform: Multicharts
Broker: Ironbeam, Rithmic
Trading: Emini ES / NQ / CL / RTY / YM / BTC
 
syswizard's Avatar
 
Posts: 223 since Jan 2019
Thanks: 12 given, 101 received


gurji View Post
Thanks, but something still not right. This is what I have. tgamt is trigger amount in ticks for when to start the trail stop.
slamt is the stop loss amount in ticks.

Both tgamt and slamt must be specified in DOLLARS, not BigPoints, not Ticks.
If you need to, convert your input in ticks to dollars:
So use this: tgamt_ticks * dollarspertick, slamt_ticks * dollarspertick

Reply With Quote
 
(login for full post details)
  #5 (permalink)
gurji
Miami, Florida
 
 
Posts: 25 since Apr 2022
Thanks: 1 given, 8 received


syswizard View Post
Both tgamt and slamt must be specified in DOLLARS, not BigPoints, not Ticks.
If you need to, convert your input in ticks to dollars:
So use this: tgamt_ticks * dollarspertick, slamt_ticks * dollarspertick


Ok, my mistake. tgamt and slamt are dollar amounts. Not ticks.
Regardless, that didn't solve it. I even changed the IF statement to check is Openpositionprofit is greater than 0, and it still returns false.

 
Code
value7 = Text_New(Date, Time, High, NumToStr(Openpositionprofit,0));
if MarketPosition <> 0 and Openpositionprofit >= 0  Then
	SetProfitTarget(trailExit) Else
	SetProfitTarget(tgamt);
value7 just prints the value of Openpositionprofit on the chart just so that I can confirm it has a value, which it does. But for some reason, it returns false when tested to see if it is greater than 0.

Reply With Quote
 
(login for full post details)
  #6 (permalink)
 syswizard 
Philadelphia PA
 
Experience: Advanced
Platform: Multicharts
Broker: Ironbeam, Rithmic
Trading: Emini ES / NQ / CL / RTY / YM / BTC
 
syswizard's Avatar
 
Posts: 223 since Jan 2019
Thanks: 12 given, 101 received


gurji View Post
Ok, my mistake. tgamt and slamt are dollar amounts. Not ticks.
Regardless, that didn't solve it. I even changed the IF statement to check is Openpositionprofit is greater than 0, and it still returns false.

 
Code
value7 = Text_New(Date, Time, High, NumToStr(Openpositionprofit,0));
if MarketPosition <> 0 and Openpositionprofit >= 0  Then
	SetProfitTarget(trailExit) Else
	SetProfitTarget(tgamt);
value7 just prints the value of Openpositionprofit on the chart just so that I can confirm it has a value, which it does. But for some reason, it returns false when tested to see if it is greater than 0.

Something is wrong with your signal's set-up and properties.
Try using PositionProfit(0) in place of OpenPositionProfit.
This code is within a SIGNAL, correct ?
Note: it won't work in an INDICATOR.

Reply With Quote
 
(login for full post details)
  #7 (permalink)
gurji
Miami, Florida
 
 
Posts: 25 since Apr 2022
Thanks: 1 given, 8 received


syswizard View Post
Something is wrong with your signal's set-up and properties.
Try using PositionProfit(0) in place of OpenPositionProfit.
This code is within a SIGNAL, correct ?
Note: it won't work in an INDICATOR.

It is in a strategy.
I'll try that and post back here.

Reply With Quote
 
(login for full post details)
  #8 (permalink)
gurji
Miami, Florida
 
 
Posts: 25 since Apr 2022
Thanks: 1 given, 8 received


syswizard View Post
Something is wrong with your signal's set-up and properties.
Try using PositionProfit(0) in place of OpenPositionProfit.
This code is within a SIGNAL, correct ?
Note: it won't work in an INDICATOR.

Ok, I see what the problem is, I just don't know how to fix it.
PositionProfit or openPositionProfit both show the profit at the close of the previous candle. But show 0 for the current candle. So 0 is never >= to tgamt, and therefore it doesn't trigger the trail stop.

Reply With Quote
 
(login for full post details)
  #9 (permalink)
gurji
Miami, Florida
 
 
Posts: 25 since Apr 2022
Thanks: 1 given, 8 received


syswizard View Post
Something is wrong with your signal's set-up and properties.
Try using PositionProfit(0) in place of OpenPositionProfit.
This code is within a SIGNAL, correct ?
Note: it won't work in an INDICATOR.

Ok, it is absolutely what I said. The trigger to start the the trail stop order isn't working, because it is looking at the close price of the previous bar and not the current price of the current candle.

Reply With Quote
 
(login for full post details)
  #10 (permalink)
 syswizard 
Philadelphia PA
 
Experience: Advanced
Platform: Multicharts
Broker: Ironbeam, Rithmic
Trading: Emini ES / NQ / CL / RTY / YM / BTC
 
syswizard's Avatar
 
Posts: 223 since Jan 2019
Thanks: 12 given, 101 received



gurji View Post
Ok, it is absolutely what I said. The trigger to start the the trail stop order isn't working, because it is looking at the close price of the previous bar and not the current price of the current candle.

That is not the correct behavior as the Set statements should be active in the current bar. They are designed to operate INTRABAR and don't require [IntraBarOrderGeneration] to be on. It is independent of that condition.
The only thing I can think of is that the Set statement is not being called after the close of the last bar. It must be called in order to be active.

Please contact MC tech support with this problem and be ready to demonstrate this problem.

Reply With Quote


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Another Trail Stop question


Last Updated on September 21, 2022


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
     



Copyright © 2022 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), info@futures.io
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