Possible to print these values only once?

How to create strategies and indicators
Message
Author
yameen.forex
Posts: 10
Joined: Tue Dec 25, 2012 9:33 pm

Possible to print these values only once?

#1 Postby yameen.forex » Fri Oct 25, 2013 5:01 am

How can I print or calculate only when the 60 minute candle closes? Your help would be appreciated...!!! Please refer to the attachment, my print is repeating multiple times. Also, take a look at the code.

procedure Calculate(index: integer); stdcall;

begin
if (index <> 0) or (Bars < 10) then
exit;

Print (IntToStr(index));

Print(ConCat('Time: ', FormatDateTime('DD-MM-YYYY HH:mm:nn', Time(0))));
Print(ConCat('High: ', FloattoStr(iHigh(Symbol, 60, 0))));
Print(ConCat('Low: ', FloattoStr(iLow(Symbol, 60, 0))));

TotalCandleSize := Abs((iHigh(Symbol, 60, 0) - iLow(Symbol, 60, 0)));

Print(ConCat('Difference : ', FloatToStr(TotalCandleSize)));

Attachments
25-10-2013 5-57-33 PM.png
25-10-2013 5-57-33 PM.png (53.02 KiB) Viewed 8407 times

KelvinHand
Posts: 103
Joined: Sun Jan 02, 2011 6:05 pm

Re: Possible to print these values only once?

#2 Postby KelvinHand » Fri Oct 25, 2013 7:09 pm

yameen.forex wrote:How can I print or calculate only when the 60 minute candle closes? Your help would be appreciated...!!! Please refer to the attachment, my print is repeating multiple times. Also, take a look at the code.

procedure Calculate(index: integer); stdcall;

begin
if (index <> 0) or (Bars < 10) then
exit;

Print (IntToStr(index));

Print(ConCat('Time: ', FormatDateTime('DD-MM-YYYY HH:mm:nn', Time(0))));
Print(ConCat('High: ', FloattoStr(iHigh(Symbol, 60, 0))));
Print(ConCat('Low: ', FloattoStr(iLow(Symbol, 60, 0))));

TotalCandleSize := Abs((iHigh(Symbol, 60, 0) - iLow(Symbol, 60, 0)));

Print(ConCat('Difference : ', FloatToStr(TotalCandleSize)));




Try this

Code: Select all

procedure Calculate(index: integer); stdcall;
var
  dt : TDateTime;
  TotalCandleSize, Hi, Lo    : double;

begin

  // create text
  if (index <> 0) or (Bars < 10) then exit;

    dt:= Time(index);

    Hi:=iHigh(Symbol, PERIOD_H1, index);
    Lo:=iLow (Symbol, PERIOD_H1, index);
    TotalCandleSize := Hi-Lo;

    if  (HourOf(dt) = 1) and (MinuteOf(dt)=0) and (SecondOf(dt)=0 ) then
     begin
      Print (
       'Index: ' + IntToStr(index) +
       ', Time: '+ DateTimeToStr(dt) +
       ', High: '+ FloatToStr(Hi) +
       ', Low: ' + FloatToStr(Lo) +
       ', Diff: '+FloatToStr(TotalCandleSize)
       )
     end;


end;



Return to “FT API”

Who is online

Users browsing this forum: No registered users and 20 guests