🏷 기능 CopyRates()/CopyClose():历史数据批量读取
MT5 读历史 K 线的标配기능。
【基本用法】MqlRates rates[]; int n = CopyRates(Symbol(), PERIOD_H1, 0, 100, rates); 一次取 100 根 H1 K 线(含 OHLC、tick_volume、spread、time)。
【两种取法】
- 起点模式:CopyRates(symbol, tf, start_pos, count, array);
- 시간模式:CopyRates(symbol, tf, start_time, stop_time, array)。
【配合 ArraySetAsSeries】CopyBuffer/CopyRates 반품数组기본값 index0=最旧,SetAsSeries(rates, true) 后 index0=최신,写전략逻辑更直观。
【반품值检查】n<0 是실패하다(数据未加载完,用 BarsCalculated 检查),n<count 是部分성공——都要처리。
【性能建议】每根 K 线只복사一次(新 K 线检测后再새로 고치다),不要每个 tick 都全量복사,回测速度差十倍。
【基本用法】MqlRates rates[]; int n = CopyRates(Symbol(), PERIOD_H1, 0, 100, rates); 一次取 100 根 H1 K 线(含 OHLC、tick_volume、spread、time)。
【两种取法】
- 起点模式:CopyRates(symbol, tf, start_pos, count, array);
- 시간模式:CopyRates(symbol, tf, start_time, stop_time, array)。
【配合 ArraySetAsSeries】CopyBuffer/CopyRates 반품数组기본값 index0=最旧,SetAsSeries(rates, true) 后 index0=최신,写전략逻辑更直观。
【반품值检查】n<0 是실패하다(数据未加载完,用 BarsCalculated 检查),n<count 是部分성공——都要처리。
【性能建议】每根 K 线只복사一次(新 K 线检测后再새로 고치다),不要每个 tick 都全量복사,回测速度差十倍。
🔥 이 사용자의 인기 게시글
🆕 이 사용자의 최신 게시글
답글(0)
아직 답글이 없습니다. 첫 댓글을 남겨보세요!