Simple Coding Help - No Promise.

Is it possible to write such a strategy?


let's say;

I have 2 buy and 2 sell condition formula

Example

buy1=close>MA(close,20);

buy2=close>MA(close,50);

sell1=close<MA(close,20);
sell2=close<MA(close,50);

- in the same day for buy, we use buy2 ( same day with sell, it is previous trade) , And the next day from the previous trades we use buy 1

- for sell ; with previous trade ( buy1 or buy 2) we use for sell , sell 2 rule, and next day for sell we use sell1..

Is it possible that the formula.Could you please give an example .
I think it can be done with TIMENUM or DATETIME.
 
Hi,

can I kindly ask for a small portion of code which will display lowest low from three last significant candles? What I mean by significant is that if one of them is engulfed it kind of doesn't count. I tried to illustrate it here:

https://s9.postimg.org/g76508xxr/image.png

I would like to have lowest low displayed as a horizontal red line, below price action (to act as a stop loss signal).

I would appreciate your help so much!
Nigel
 
Hi,

can I kindly ask for a small portion of code which will display lowest low from three last significant candles? What I mean by significant is that if one of them is engulfed it kind of doesn't count. I tried to illustrate it here:

https://s9.postimg.org/g76508xxr/image.png

I would like to have lowest low displayed as a horizontal red line, below price action (to act as a stop loss signal).

I would appreciate your help so much!
Nigel
What are the rules for significant candles?

Can you define them in mathematical terms?

Plotting your Red line will be easily possible if you can define the significant candles.

Happy :)
 
What are the rules for significant candles?

Can you define them in mathematical terms?

Plotting your Red line will be easily possible if you can define the significant candles.

Happy :)
Hi Happy_Singh!

Thanks for your response, I'm so frustrated not being able to code it :)
Ok, so here is my attempt to describe it in a more logical way (quasi code)

Code:
1. Select start date and mark current candle as number 1
(it would be great to be able to choose the date in parameters, but if it's too complicated I can edit the code each time to mark the start date manually)

Code:
2. Look back another day
if 
{lowest price of current day is lower than the lowest price of the next day (candle number 1)}

then {
mark that candle as number +1}

else {
ignore that candle and look back another day
}

Repeat until the counter shows 3 (candles)
Code:
3. Plot a horizontal line from a lowest point of a candle (lowest price level of the day) marked as number 3
------

IF POSSIBLE:
Code:
4. plot the horizontal line until stopped out, that is if one of the future candles closes below the horizontal line
OMG it was not so easy! I'd never become a coder :) Still, is this description good enough for you to be able to help me?:)

Thanks!!!!
Nigel
 
Last edited:
Hi Nigel

Will look into it after the market hours.

But choosing the date in parameters is built in

Code:
mydate = ParamDate("MyDate","10/10/2016");
Happy :)
 
Hello all :thumb: and thanks for advanced help
Can anyone convert this very easy code from Tradestation to afl
i use this for reversal trading in ts thanks for your help.

Code:
Variables:BB_DC(0),CTD(0);

IF LOW > BollingerBand(CLOSE, 48,-1.8) THEN BB_DC=   0;
IF LOW < BollingerBand(CLOSE, 48,-1.8) THEN BB_DC= -1.24;

IF BB_DC[1] = -1.24 THEN  CTD = -2.8; 
IF CTD <> 0 THEN CTD = CTD +.3; 
IF CTD >0 THEN CTD =0;
BB_DC=BB_DC + CTD; 
IF BB_DC < -1.24 THEN BB_DC = -1.24;
SH_BANDS =BB_DC ;

plot1(SH_BANDS,"SH_BANDS");
 

cellclinic

Well-Known Member
Hello Friends :)

Again Needed a help ...

1. Price Below day open sell only or above open Buy Only
2. Buy Only If Price Is Above Open Of The Day & RSI 39 Above 50 Level Vice Versa For Sell Condition
3. Exit Only If Rsi 39 Is Below 50 Levels & Price Is Below 39 EMA Vice Versa For Sell Condition
4. Re-enter If Price Remains Above Day Open & Closed Above 39 EMA Along With 39 RSI Closed Above 50 Level Same For Sell Conditions
5. Needed Buy - Sell & Short - Cover For Entry & Exit & Re - Entry .

Hoping It Is Not Complicated To Masters :)

Thanks In Advance Jee :)
 
I have one afl with me but want one modification . i want to see difference between bull and bear volume in figure as shown upside near total volume. If bull volume is in +ve then bull volume showing and bear volume in negative and similarly for bear. So that easy to judge who is dominating market currently. If great coding people can help may be helpful to others
..........................................................................................................................................
formulaName = "Sum of Bull and Bear Volumes";
SetChartOptions(0,chartShowArrows|chartShowDates);
GfxSetBkMode(1);
GfxSelectFont("Verdana", 12, 600, italic=False);
GfxSetTextColor(colorLightYellow);
GfxTextOut(FormulaName, 4, 20);


_SECTION_BEGIN("Sum of Bull and Bear Volumes");
SetChartOptions(0, chartShowArrows|chartShowDates);
GfxSetBkMode(1);
periods = Param("Periods to Sum", 5, 1, 100, 1);

BullCond = V>Ref(V,-1) AND C>Ref(C,-1) OR V<Ref(V,-1) AND C<Ref(C,-1);
BearCond = V>Ref(V,-1) AND C<Ref(C,-1) OR V<Ref(V,-1) AND C>Ref(C,-1);

SumBull= Sum (V*BullCond, periods);
SumBear= Sum (V*BearCond, periods);
Delta = SumBull-SumBear;
Summa = SumBull+SumBear;

Out = ParamToggle("Show Style", "Bull+Bear|Bull-Bear", 0 );
if ( Out == 0 )
{
GraphXSpace = 20;
Plot(SumBull,"Bull Vol", colorLime, styleThick);
Plot(SumBear,"Bear Vol", colorRed, styleThick);
Plot(SumBear,"", colorBrown, styleHistogram|styleNoLabel|styleNoTitle);
Plot(SumBull,"", colorDarkGreen, styleHistogram|styleNoLabel|styleNoTitle);
Plot(Summa, "All Vol", colorWhite, styleDashed|styleNoRescale);
}
else
{
GraphXSpace = 10;
DeltaColor = IIf( Delta==0, colorWhite, IIf(Delta>0, colorGreen,colorRed));
Plot(Delta,"Delta", DeltaColor, styleLine|styleNoLine|styleNoRescale);
Plot(Delta,"Delta", colorWhite, styleThick|styleNoLabel|styleNoTitle|styleNoRescale);
PlotOHLC(Delta,Delta,0,Delta,"",DeltaColor, styleCloud|styleClipMinMax|styleNoLabel);
}
_SECTION_END();
 

Similar threads