To do something on Buy/Short Signal in Scanner

Hi ,

I am trying to open an exe, when the signal is generated by SCANNER(NOT BACKTEST).
I search a lot Internet but no luck was found.

Please help me.

@Tomasz

Please help me

Try ShellExecute !

Hi, thanks for your response. That function I know. But what is the main root of code? Can you please share the entire Afl code? For. eg. Let's take Buy and Sell on Crossover(50,200).

I don't know where to write ShellExecute();

Video gif. A man in an elaborate suit smirks slightly as he slow claps beneath a flashing light box that says, "Applause."

1 Like
Buy = prev_FastEMA > (prev_SlowEMA*(1 + (BuyGap/100))) AND IsValidEntryTimeAndOpen;
BuyPrice = ValueWhen(Buy,O);
Sell = Cross(prev_SlowEMA,prev_FastEMA) OR Open <= 10;
SellPrice = ValueWhen(Sell,O);

Short = prev_FastEMA < (prev_SlowEMA*(1 - (ShortGap/100))) AND IsValidEntryTimeAndOpen;
ShortPrice = ValueWhen(Short,O);
Cover =  Cross(prev_fastEMA,prev_SlowEMA);
CoverPrice = ValueWhen(Cover, O);

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short = ExRem(Short,Cover);
Cover=ExRem(Cover,Short);

PlotShapes(IIf(Buy,shapeUpTriangle,Null),colorWhite,0,H,-45);
PlotShapes(IIf(Sell,shapeDownTriangle,Null),colorWhite,0,L,-45);
PlotShapes(IIf(Short,shapeDownTriangle,Null),colorYellow,0,L,-60);
PlotShapes(IIf(Cover,shapeUpTriangle,Null),colorYellow,0,H,-60);

This is the code. Tell me where to write ShellExecute(); If you know please help. I am new to AFL.

From your responses, your end goal is clear but not your intention.

For e.g., what that .exe does? Why do you even need to run an external .exe?

99.99% of stuffs can be achieved through AFL itself.

Carefully read:

The exe is the command line. It places the orders to the broker. I can also use InternetPostRequest(). But, I don't know how to verify the current BUY/SHORT signal. Actually, I don't know which code is required to capture the signal.

I would strongly recommend to do your experimentation with AlertIF instead of going full-on and sending orders to your broker.
The lack of programming knowledge would cost you $$$ if you blindly send orders without making sure that the code is correct.

Also AlertIf includes internal logic that prevents repeated orders to be sent

http://www.amibroker.com/guide/afl/alertif.html

For example if you do this:

if( LastValue( Buy ) )
{
   ShellExecute(....); // this would possibly execute MANY times (each time you run scan) and you would end up with multiple orders
}

If you are not using AlertIf you have to implement your own logic that preserves the STATE (using static variables).

You really need to LEARN a lot before you send orders directly to your broker. Recommended reading is entire UserKB
https://www.amibroker.org/userkb/

Okay. I am trying with alertif. I will share the result with you.

Thank You.
:slight_smile:

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.