Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
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 for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Dear friends
Please help a newbie here - am trying to add dailyprofittarget and dailyloss to a simple moving average cross strat.. I added a dailyprofit/loss code that Big Mike posted a long time ago here...what's wrong there?
Thanks for ANY help!
This is the code:
// for use in signal
inputs:
dailyprofit(500),
dailyloss(250);
vars:
todaynet(0),
yesterdaynet(0);
if date <> date[1] then begin
yesterdaynet = NetProfit;
end;
if MarketPosition = 0 then begin
todaynet = NetProfit - yesterdaynet;
end;
condition1 = -dailyloss < todaynet and todaynet < dailyprofit;
// entries
if condition 1 then begin
inputs:
FastPrice( Close ) [DisplayName = "FastPrice", ToolTip =
"Enter an EasyLanguage expression to use in calculation of shorter length moving average."],
SlowPrice( Close ) [DisplayName = "SlowPrice", ToolTip =
"Enter an EasyLanguage expression to use in calculation of longer length moving average."],
FastLength( ) [DisplayName = "FastLength", ToolTip =
"Enter number of bars to use in calculation of shorter length moving average."],
SlowLength( ) [DisplayName = "SlowLength", ToolTip =
"Enter number of bars to use in calculation of longer length moving average."];
{ CB > 1 check used to avoid spurious cross confirmation at CB = 1 }
if CurrentBar > 1 and FastAvg crosses under SlowAvg then
Sell short 1 contract next bar at market;
setstoploss ();
setprofittarget ();
{ ** Copyright Đ TradeStation Technologies, Inc. All Rights Reserved **
** TradeStation reserves the right to modify or overwrite this strategy component
with each release. ** }
end;
Can you help answer these questions from other members on NexusFi?
I think this is your problem, there isn't any variable or input placed in the target and stop functions. Put your profit and stop inputs inside the parentheses.
condition1 = -dailyloss < todaynet and todaynet < dailyprofit;
Instead of -dailyloss use -1*dailyloss.
For generating a buy or sell signal, I didn't have to use "if condition1 then begin;end";
I just insert the condition along with the rest of the buy or sellshort instructions. example: If condition1 and value1>value2 then buy/sellshort next bar market;