NexusFi: Find Your Edge


Home Menu

 





Have problem with trailing stop


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one kissdish with 3 posts (1 thanks)
    2. looks_two Quick Summary with 1 posts (0 thanks)
    3. looks_3 ABCTG with 1 posts (1 thanks)
    4. looks_4 Jura with 1 posts (0 thanks)
    1. trending_up 3,146 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
kissdish
nanjing china
 
Posts: 3 since Jul 2015
Thanks Given: 0
Thanks Received: 1

I want to write a custom trailing stop, the code snippets like this

if MarketPosition <> 0 then
begin
tStopLoss = VerifyStopLoss(value4, AvgValue, OrderSlot, BuyOrSell, LogLevel);

if tStopLoss <> 0 then
begin
value4 = tStopLoss;
end;

if BuyOrSell <> 0 then
begin
sell next bar at value4 stop;
end
else
begin
buytocover next bar at value4 stop;
end;
end;

the VerifyStopLoss function will caculate the new stop price and i know it work correctly, now the problem is that no any stop order will be submitted while the sa model is turned on, i dont know why.


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MegaETH Proves the Crowd Right: Prediction Markets Calle …
Prediction Markets & Event Contracts
$134M Ground Entry Contract in Disputed Final Review Aft …
Prediction Markets & Event Contracts
New Section 301 Probes Target 16 Trading Partners -- Tra …
Traders Hideout
GDP Day: The First Economic Reckoning -- Pahlavi at 6.55 …
Prediction Markets & Event Contracts
Cboe Files for Near 24x5 Equities Trading -- December 20 …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
21 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639


kissdish,

it's hard for anyone to guess what could be the problem without being able to check the values from the function. You should add print commands to your code and check the values yourself to see if they are correct. This will help you to track the issue down.

Regards,
ABCTG


Follow me on X Reply With Quote
Thanked by:
  #4 (permalink)
kissdish
nanjing china
 
Posts: 3 since Jul 2015
Thanks Given: 0
Thanks Received: 1

thank you for your reply, i have checked the function and ensure it will return correct value, now i wondered is there anything wrong i use the sell and buytocover command, as no any stop order be submitted. does anyone know that if i want to write a custom trailing stop, what function or command is the standard method, setstoploss?


Reply With Quote
  #5 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690


kissdish View Post
i have checked the function and ensure it will return correct value, now i wondered is there anything wrong i use the sell and buytocover command, as no any stop order be submitted.

Do you have an open position when this script is applied to the chart? That's all I can guess based on the information you've provided.


kissdish View Post
does anyone know that if i want to write a custom trailing stop, what function or command is the standard method, setstoploss?

The code snippet that you showed already is a custom stop; you only need to make it trailing. If you implement SetDollarTrailing() then it won't be custom anymore.


Reply With Quote
  #6 (permalink)
kissdish
nanjing china
 
Posts: 3 since Jul 2015
Thanks Given: 0
Thanks Received: 1

thanks for your replay, i have solved this problem, the reason is the marketpostion will always return 0 while the SA is turned on, it's incorrect, maybe some bug with the broker's plug-in, i change a broker or use marketpostion_at_broker and the code run well. thank you all


Reply With Quote
Thanked by:




Last Updated on August 14, 2015


© 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