Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 600 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Strategy Development #475456
12/11/18 12:43
12/11/18 12:43
Joined: Apr 2018
Posts: 46
M
MINER Offline OP
Newbie
MINER  Offline OP
Newbie
M

Joined: Apr 2018
Posts: 46
Hello community,
I have a script as shown below, i intend the script to be using current price and an indicator(EMA) in my case. The barperiod is 1440. i would like the script to enter a trade without waiting for the current running bar to be closed as it is not using priceclose but the current price. i would also like the script to exit the trade when the indicator crosses the price on opposite direction. the script is below and attached is what i intend the script to be doing. The white line is the indicator whereas the other line is the price(AUDUSD) in my case. Kindly help on how to update the script to produce the desired script....

I like Zorro Though, ...


function run()
{
StartDate = 2011;
EndDate = 2018;
set(TICKS);
Lots = 300;
BarPeriod = 1440;
LookBack = 150;
MaxLong = 1;
MaxShort = 1;

Stop = 50*PIP;
Trail = 1.5*ATR(14);
//TrailLock = 1;


vars EMA7 = series(EMA(Close, 7));
vars Price = series(price());

if(Price[0] > EMA3[0])
enterLong();
//if(Close[0] < Close[2])
//exitLong()

if(Price[0] < EMA3[0])
enterShort();
//if(Close[0] Close[])
//exitShort

plot("EMA3", EMA3[0], 0, BLUE);

set(PLOTNOW);
PlotWidth = 1200;
PlotHeight1 = 350;
}

Attached Files PRICE AND INDICATOR.PNG
Re: Strategy Development [Re: MINER] #475457
12/11/18 12:52
12/11/18 12:52
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
You're using run(), which only operates on the close of a bar.
https://zorro-project.com/manual/en/run.htm

For tick-based entries (as opposed to bar-based), use tick().
https://zorro-project.com/manual/en/tick.htm

Also, see here for the definition of price():
https://zorro-project.com/manual/en/price.htm

Basically, this is not MT4. laugh

Re: Strategy Development [Re: AndrewAMD] #475458
12/11/18 13:00
12/11/18 13:00
Joined: Apr 2018
Posts: 46
M
MINER Offline OP
Newbie
MINER  Offline OP
Newbie
M

Joined: Apr 2018
Posts: 46
Thank once more AndrewAMD, let me implement that and will get back to you.

Re: Strategy Development [Re: MINER] #475460
12/11/18 13:22
12/11/18 13:22
Joined: Apr 2018
Posts: 46
M
MINER Offline OP
Newbie
MINER  Offline OP
Newbie
M

Joined: Apr 2018
Posts: 46
Andrew please can you guide me on how to do it because my solution is generating error 041: invalid call in TMf! and error 111: crash in tick() at bar 67......
have just replace run with tick and this is reason for these errors.

illustrate to me with an example please.....this is using a lot of my brain.

Re: Strategy Development [Re: MINER] #475464
12/11/18 15:55
12/11/18 15:55
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
You cannot use series() in tick(). You can only use series() in run().
https://zorro-project.com/manual/en/series.htm

You are attempting to do metatrader-style coding, which I discourage. These issues are discussed in the manual:
https://zorro-project.com/manual/en/conversion.htm

Quote:
"Meta"-Trader 4 (MQ4)

This is a popular platform for private traders and provided by most brokers. The MQ4 script language of its "Expert Advisors" (EAs) is based on C, which would theoretically allow easy conversion to Zorro's lite-C. Unfortunately, MQ4 has many issues that make "Expert Advisors" a lot more complex and difficult to handle than scripts of other platforms.

The MQ4 main script runs at every tick. This means that the last price candle is normally incomplete, so indicators in EAs return a different value than the same indicators in other platforms. For fixing this, the EA must check if the candle is complete, or the indicator must be shifted so that its last value is from the previous candle. Trades are not managed by the platform, but must be managed by code in the script. Series are not natively supported, but emulated with loops and functions. Indicators often produce different results in MQ4 than in other platforms because the MQ4 standard indicators do not use their standard algorithms, but special MQ4 variants. Time zones and account parameters are not normalized, so EAs must be individually adapted to the broker. To complicate matters further, MQ4 does not use common trade units such as lots and pips, but calculates with "standard lots" and "points" that need to be multiplied with account-dependent conversion factors. Most code in an EA is therefore not used for the trade algorithm, but for working around all those problems. This results in the long and complex 'spaghetti code' that is typical for EAs.


Re: Strategy Development [Re: AndrewAMD] #475466
12/12/18 08:10
12/12/18 08:10
Joined: Apr 2018
Posts: 46
M
MINER Offline OP
Newbie
MINER  Offline OP
Newbie
M

Joined: Apr 2018
Posts: 46
Thank you, i appreciate your information @AndrewAMD

Re: Strategy Development [Re: MINER] #475477
12/13/18 01:08
12/13/18 01:08
Joined: Aug 2018
Posts: 98
O
OptimusPrime Offline
Junior Member
OptimusPrime  Offline
Junior Member
O

Joined: Aug 2018
Posts: 98
Thank you AndrewAMD


Thanks so much,

OptimusPrime


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1